#include "Node.h"
#include "DataDefine.h"
#include "MetaDataIO.h"

namespace gitstore {
CNodeOperation::CNodeOperation() {

}

CNodeOperation::~CNodeOperation() {

}

ErrorStatus CNodeOperation::dump(shared_ptr<CMetaDataIOBase> io_worker, const Node& node) {
    return io_worker->saveNode(node);
}

ErrorStatus CNodeOperation::load(shared_ptr<CMetaDataIOBase> io_worker, const std::string& ds_name, const std::string& version, Node& node) {
    return io_worker->loadNode(ds_name, version, node);
}

ErrorStatus CNodeOperation::create(const std::string& ds_name, const std::string& version, const std::string& note, int type, const std::vector<std::string>& parents, Node& node) {
    node.ds_name = ds_name;
    node.version = version;
    node.parents.insert(node.parents.begin(), parents.begin(), parents.end());
//    std::copy(parents.begin(), parents.end(), node.parents.begin());
    node.note = note;
    node.type = type;
    time_t t;
    t=time(&t);
    node.date = t;
    return Success;
}
}
